var CanvasUtil = {
    getContext2D:function (id) {
        var canvas = document.getElementById(id);
        if (canvas.getContext) {
            var context = canvas.getContext('2d');
            return context;
        }
    },
    
    stroke:function (canvas,tx,ty,width,height,lineWidth,strokeStyle) {
        if (typeof(canvas) == "string") {
            canvas = this.getContext2D(canvas);
        }
        lineWidth = lineWidth?lineWidth:1;
        strokeStyle = strokeStyle?strokeStyle:"#000000";
        canvas.lineWidth = lineWidth;
        canvas.strokeStyle = strokeStyle;
        canvas.strokeRect(tx,ty,width,height);
        return canvas;
    },
    fillRect:function (canvas,tx,ty,width,height,fillStyle) {
        fillStyle = fillStyle?fillStyle:"#000000";        
        canvas.fillStyle = fillStyle; //可以是字符串或者样式对象
        canvas.fillRect(tx,ty,width,height);
        return canvas;
    },
    
};